package com.bwie.user.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.bwie.user.entity.ComeEntity;
import com.bwie.user.service.ComeService;
import com.bwie.common.utils.PageUtils;
import com.bwie.common.utils.R;



/**
 * 
 *
 * @author ShuangzhiZhao
 * @email 466505908@qq.com
 * @date 2022-02-17 08:56:51
 */
@RestController
@RequestMapping("user/come")
public class ComeController {
    @Autowired
    private ComeService comeService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = comeService.queryPage(params);

        return R.ok().put("page", page);
    }
    @RequestMapping("/comeList")
    public List<ComeEntity> comeList(){
        return comeService.list();
    }



    /**
     * 信息
     */
    @RequestMapping("/info/{cid}")
    public R info(@PathVariable("cid") Integer cid){
		ComeEntity come = comeService.getById(cid);

        return R.ok().put("come", come);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody ComeEntity come){
		comeService.save(come);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody ComeEntity come){
		comeService.updateById(come);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] cids){
		comeService.removeByIds(Arrays.asList(cids));

        return R.ok();
    }

}
